<template>
  <div>
    <el-menu
      :default-active="$route.path"
      class="el-menu-vertical-demo"
      @open="open"
      @close="close"
      @select="selectSide"
      router
      background-color="#545c64"
      text-color="#fff"
      active-text-color="#ffd04b">
      <el-submenu index="1">
        <template slot="title">
          <i class="el-icon-user"></i>
          <span>{{userData.name}}</span>
        </template>
        <el-menu-item v-for="(item,index) in userData.usersModules" :index="item.path" :key="index">
          {{item.name}}
        </el-menu-item>
      </el-submenu>
      <el-submenu index="2">
        <template slot="title">
          <i class="el-icon-s-goods"></i>
          <span>{{modules.name}}</span>
        </template>
        <el-menu-item v-for="(item,index) in modules.modulesArr" :index="item.path" :key="index">
          {{item.name}}
        </el-menu-item>
      </el-submenu>
    </el-menu>
  </div>
</template>

<script>
    export default {
        name: "side",
      data(){
          return {
            userData: {name: '个人中心',
            usersModules: [{path: '/index/userInformation',name: '个人信息'},{path: '/index/modification',name: '个人信息修改'}]},
            modules: {
              name: '模块一',
              modulesArr: [{path: '/index/module_11',name:'价格与销量'}]
            }
          }
      },
      methods:{
          open:function (index, path) {
            console.log(index,path);
          },
          close: function (index, path) {
            console.log(index,path);
          },
          selectSide: function (index, path) {
            console.log(index,path);
          }
      }
    }
</script>

<style scoped>

</style>
